package tank;

import java.awt.*;

/**
 * @Auther: xiaofei
 * @Date: 2021/6/9 - 06 - 09 - 16:10
 * @Description: tank
 * @version: 1.0
 */
//抽象出坦克类，封装相应的属性和方法，在TankFrame中直接调用
public class Tank {
    private int x,y;
    private Dir dir = Dir.DOWN;
    private static final int SPEED = 10;

    private boolean moving = false;

    public Dir getDir() {
        return dir;
    }

    public void setDir(Dir dir) {
        this.dir = dir;
    }

    public Tank(int x, int y, Dir dir) {
        super();
        this.x = x;
        this.y = y;
        this.dir = dir;
    }

    public void paint(Graphics g){
        //myTank.paint(g);
        //建立一个矩形
        g.fillRect(x,y,50,50);

        //move();

        //根据坦克方向
        switch(dir){
            case LEFT:
                x -= SPEED;
                break;
            case UP:
                y -= SPEED;
                break;
            case RIGHT:
                x += SPEED;
                break;
            case DOWN:
                y += SPEED;
                break;
        }
    }
}
